﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="King.cs" company="">
//   
// </copyright>
//  <summary>
//   The king.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Shatranj
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// The king.
    /// </summary>
    public class King : ChessPiece
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="King"/> class.
        /// </summary>
        /// <param name="currentSquare">
        /// The current square.
        /// </param>
        /// <param name="force">
        /// The force.
        /// </param>
        public King(BoardSquare currentSquare, Army force)
            : base(currentSquare, force)
        {
            this.Identity = Piece.King;

            this.CanJumpOver = false;
            this.IsPromotable = false;
            this.Enpassant = false;
            this.CanCaptureAcross = true;
            this.InitialMaxStepAllowed = false;
            this.InitialMaxStep = 0;

            this.AltChar = (this.Force == Army.White) ? 'k' : 'l';
            this.CharNotationAsNumber = (this.Force == Army.White) ? 107 : 108;

            var i = 0;

            if (this.MovePaths != null)
            {
                return;
            }

            var movePaths = new Dictionary<string, ICollection<MovePath>>();
            foreach (MoveDirection direction in Enum.GetValues(typeof(MoveDirection)))
            {
                movePaths.Add(
                    (++i).ToString(), 
                    new List<MovePath> { new MovePath { Direction = direction, Ordinal = 1, MinStep = 1, MaxStep = 1 } });
            }

            this.SetMovePaths(this.Identity, movePaths);
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The move.
        /// </summary>
        /// <param name="newLocation">
        /// The new location.
        /// </param>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public override bool Move(BoardSquare newLocation, MoveOptions options)
        {
            if (this.IsLegal(newLocation))
            {
                this.CurrentLocation = newLocation;
            }

            return false;
        }

        /// <summary>
        /// The move.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public override bool Move()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}